﻿using System;
using System.Windows.Forms;
using AsyncLibrary.StatusListener;

namespace AsyncLibrary.UI
{
  public class ProgressBarListener : ControlListenerBase
  {
    private readonly ProgressBar _progressBar;

    public ProgressBarListener(ProgressBar progressBar) : base(progressBar)
    {
      _progressBar = progressBar;
    }

    public override void SetProgress(int value)
    {
      _progressBar.Value = value;
    }

    public override void SetProgresMax(int value)
    {
      _progressBar.Maximum = value;
    }

    public override void SetMode(StatusProgressMode value)
    {
      switch (value)
      {
        case StatusProgressMode.Progress:
          _progressBar.Style = ProgressBarStyle.Continuous;
          break;
        case StatusProgressMode.Infinity:
          _progressBar.Style = ProgressBarStyle.Marquee;
          break;
        default:
          throw new ArgumentOutOfRangeException("value");
      }
    }

  }
}